/* 
 * AUTHOR: Kevin Lam
 */

package com.apps.datastore.dao;

public class ContactInformationObject {

	public enum CARRIER{
		
		NULL(""),									//NULL placer
		ALIANT("<NUMBER>@sms.wirefree.informe.ca"), //Aliant
		BELL("<NUMBER>@txt.bell.ca"), 				//Bell/Solo
		FIDO("<NUMBER>@fido.ca"),					//Fido
		KOODO("<NUMBER>@msg.telus.ca"),				//Koodo			-	5
		MTS("<NUMBER>@text.mtsmobility.com"),		//MTS Mobility
		PC("<NUMBER>@mobiletxt.ca"),				//PC Telecom
		ROGERS("<NUMBER>@pcs.rogers.com"),			//Rogers
		SASKTEL("<NUMBER>@sms.sasktel.com"),		//SaskTel
		TELUS("<NUMBER>@msg.telus.com"),			//Telus			-	10
		VIRGIN("<NUMBER>@vmobile.ca");				//Virgin
		
		String gateway;

		CARRIER(String gateway) {
			this.gateway = gateway;
		}

		public String getGateway() {
			return gateway;
		}

		public void setGateway(String gateway) {
			this.gateway = gateway;
		}

		public static CARRIER get(String gateway) {
			for (CARRIER c : values()) {
				if (c.gateway.equals(gateway))
					return c;
			}
			return null;
		}

		public String prepareGateway(String pNum) {
			return this.gateway.replace("<NUMBER>", pNum);
		}
	}
	private String emailAddress;
	private String phoneNumber;
	private long seatConfig;
	private long notifyConfig;
	private CARRIER carrier;
	
	public ContactInformationObject(){
	}
	
	public ContactInformationObject(String emailAddress, String phoneNumber,long seat, long notify, CARRIER carrier){
		this.emailAddress = emailAddress;
		this.phoneNumber = phoneNumber;
		this.seatConfig = seat;
		this.notifyConfig = notify;
		this.carrier = carrier;
	}
	
	public ContactInformationObject(String emailAddress, String phoneNumber,long seat, long notify, String gateway){
		this.emailAddress = emailAddress;
		this.phoneNumber = phoneNumber;
		this.seatConfig = seat;
		this.notifyConfig = notify;
		this.carrier = CARRIER.get(gateway);
	}

	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getEmailAddress() {
		return emailAddress;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((carrier == null) ? 0 : carrier.hashCode());
		result = prime * result
				+ ((emailAddress == null) ? 0 : emailAddress.hashCode());
		result = prime * result + (int) (notifyConfig ^ (notifyConfig >>> 32));
		result = prime * result
				+ ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
		result = prime * result + (int) (seatConfig ^ (seatConfig >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactInformationObject other = (ContactInformationObject) obj;
		if (carrier != other.carrier)
			return false;
		if (emailAddress == null) {
			if (other.emailAddress != null)
				return false;
		} else if (!emailAddress.equals(other.emailAddress))
			return false;
		if (notifyConfig != other.notifyConfig)
			return false;
		if (phoneNumber == null) {
			if (other.phoneNumber != null)
				return false;
		} else if (!phoneNumber.equals(other.phoneNumber))
			return false;
		if (seatConfig != other.seatConfig)
			return false;
		return true;
	}

	public boolean equals(ContactInformationObject cio) {
		return (   this.emailAddress.equals(cio.getEmailAddress())
				&& this.phoneNumber.equals(cio.getPhoneNumber())
				&& this.carrier == cio.getCarrier())
				&& this.notifyConfig == cio.getNotifyConfig()
				&& this.seatConfig == cio.getSeatConfig();

	}

	public CARRIER getCarrier() {
		return carrier;
	}

	public long getNotifyConfig() {
		return notifyConfig;
	}

	public long getSeatConfig() {
		return seatConfig;
	}

	public void setCarrier(CARRIER carrier) {
		this.carrier = carrier;
	}

	public void setNotifyConfig(long notifyConfig) {
		this.notifyConfig = notifyConfig;
	}

	public void setSeatConfig(long seatConfig) {
		this.seatConfig = seatConfig;
	}

}
